<?php 
/**
 *  每天定时将 关注拍品数量 投标拍品数量 竞拍拍品数量 成交数量 登录次数 数据插入au_dealer_statistics车商统计表
 */
date_default_timezone_set("Asia/Shanghai");

set_time_limit(0);

if (isset ( $_SERVER ['REQUEST_URI'] )) {
    die ( 'error' );
}
if (! defined ( 'API_ROOT_PATH' )) {
    define ( 'API_ROOT_PATH', dirname ( __FILE__ ) );
}

if (!function_exists("pcntl_fork")) {  

    die();  
}  

$cmdArr = array();  

$cmdArr[] = array("path" => __DIR__ . "/run.php",  'start' =>"2015-12-01",'end' =>"2015-12-31");  

// $cmdArr[] = array("path" => __DIR__ . "/run.php",  'start' =>"2016-05-02",'end' =>"2016-07-01");  

// $cmdArr[] = array("path" => __DIR__ . "/run.php",  'start' =>"2016-07-02",'end' =>"2016-08-22");  

echo "parent start, pid ", getmypid(), "\n" ;

pcntl_signal(SIGCHLD, SIG_IGN); 

foreach ($cmdArr as $cmd) {  

    $pid = pcntl_fork();  

    if ($pid == -1) {  

        die();  

    } else if ($pid > 0) {  
        
        pcntl_wait($status,WNOHANG); 

    } else if ($pid == 0) {  

        echo "child start, pid ", getmypid(), "\n" ;

        $path   = $cmd["path"];   

        $start = $cmd['start'] ;  

        $end = $cmd['end'] ;  

        exec("/usr/bin/php {$path} {$start} {$end} >> log.txt")."\n";  

        exit(0) ;  
    }  
}


